home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 2 / Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso / Pearls / dev / Oberon_Interfaces / Interfaces / TrackDisk.mod < prev    next >
Text File  |  1995-01-12  |  8KB  |  261 lines

  1. (*
  2. (*
  3. **  Amiga Oberon Interface Module:
  4. **  $VER: TrackDisk.mod 40.15 (12.1.95) Oberon 3.6
  5. **
  6. **   © 1993 by Fridtjof Siebert
  7. *)
  8. *)
  9.  
  10. MODULE TrackDisk;   (* $Implementation- *)
  11.  
  12. IMPORT e * := Exec;
  13.  
  14.  
  15. (*
  16.  *--------------------------------------------------------------------
  17.  *
  18.  * Physical drive constants
  19.  *
  20.  *--------------------------------------------------------------------
  21.  *)
  22.  
  23. (* OBSOLETE -- use the TD_GETNUMTRACKS command! *)
  24. (*#define       NUMCYLS 80*)            (*  normal # of cylinders *)
  25. (*#define       MAXCYLS (NUMCYLS+20)*)  (* max # cyls to look for during cal *)
  26. (*#define       NUMHEADS 2*)
  27. (*#define       NUMTRACKS (NUMCYLS*NUMHEADS)*)
  28.  
  29. CONST
  30.  
  31.   numSecs * = 11;
  32.   numUnits * = 4;
  33.  
  34.  
  35. (*
  36.  *--------------------------------------------------------------------
  37.  *
  38.  * Useful constants
  39.  *
  40.  *--------------------------------------------------------------------
  41.  *)
  42.  
  43. (*-- sizes before mfm encoding *)
  44.   sector * = 512;
  45.   secShift * = 9;    (* log TD_SECTOR *)
  46.  
  47. (*
  48.  *--------------------------------------------------------------------
  49.  *
  50.  * Driver Specific Commands
  51.  *
  52.  *--------------------------------------------------------------------
  53.  *)
  54.  
  55. (*
  56.  *-- TD_NAME is a generic macro to get the name of the driver.  This
  57.  *-- way if the name is ever changed you will pick up the change
  58.  *-- automatically.
  59.  *--
  60.  *-- Normal usage would be:
  61.  *--
  62.  *-- char internalName[] = TD_NAME;
  63.  *--
  64.  *)
  65.  
  66.   name * = "trackdisk.device";
  67.  
  68.   extCom * = 8000U;                (* for internal use only! *)
  69.  
  70.  
  71.   motor        * = e.nonstd+0;  (* control the disk's motor *)
  72.   seek         * = e.nonstd+1;  (* explicit seek (for testing) *)
  73.   format       * = e.nonstd+2;  (* format disk *)
  74.   remove       * = e.nonstd+3;  (* notify when disk changes *)
  75.   changeNum    * = e.nonstd+4;  (* number of disk changes *)
  76.   changeState  * = e.nonstd+5;  (* is there a disk in the drive? *)
  77.   protStatus   * = e.nonstd+6;  (* is the disk write protected? *)
  78.   rawRead      * = e.nonstd+7;  (* read raw bits from the disk *)
  79.   rawWrite     * = e.nonstd+8;  (* write raw bits to the disk *)
  80.   getDriveType * = e.nonstd+9;  (* get the type of the disk drive *)
  81.   getNumTracks * = e.nonstd+10; (* # of tracks for this type drive *)
  82.   addChangeInt * = e.nonstd+11; (* TD_REMOVE done right *)
  83.   remChangeInt * = e.nonstd+12; (* remove softint set by ADDCHANGEINT *)
  84.   getGeometry  * = e.nonstd+13; (* gets the disk geometry table *)
  85.   eject        * = e.nonstd+14; (* for those drives that support it *)
  86.   lastcomm     * = e.nonstd+15;
  87.  
  88. (*
  89.  *
  90.  * The disk driver has an "extended command" facility.  These commands
  91.  * take a superset of the normal IO Request block.
  92.  *
  93.  *)
  94.  
  95.   extWrite       * = e.write  + extCom;
  96.   extRead        * = e.read   + extCom;
  97.   extMotor       * = motor    + extCom;
  98.   extSeek        * = seek     + extCom;
  99.   extFormat      * = format   + extCom;
  100.   extUpdate      * = e.update + extCom;
  101.   extClear       * = e.clear  + extCom;
  102.   extRawRead     * = rawRead  + extCom;
  103.   extRawWrite    * = rawWrite + extCom;
  104.  
  105. TYPE
  106.  
  107. (*
  108.  *
  109.  * extended IO has a larger than normal io request block.
  110.  *
  111.  *)
  112.  
  113.   IOExtTDPtr * = UNTRACED POINTER TO IOExtTD;
  114.   IOExtTD * = STRUCT (req * : e.IOStdReq)
  115.     count * : LONGINT;
  116.     secLabel * : LONGINT;
  117.   END;
  118.  
  119. (*
  120.  *  This is the structure returned by TD_DRIVEGEOMETRY
  121.  *  Note that the layout can be defined three ways:
  122.  *
  123.  *  1. TotalSectors
  124.  *  2. Cylinders and CylSectors
  125.  *  3. Cylinders, Heads, and TrackSectors.
  126.  *
  127.  *  #1 is most accurate, #2 is less so, and #3 is least accurate.  All
  128.  *  are usable, though #2 and #3 may waste some portion of the available
  129.  *  space on some drives.
  130.  *)
  131.  
  132.   DriveGeometryPtr * = UNTRACED POINTER TO DriveGeometry;
  133.   DriveGeometry * = STRUCT
  134.     sectorSize * : LONGINT;          (* in bytes *)
  135.     totalSectors * : LONGINT;        (* total # of sectors on drive *)
  136.     cylinders * : LONGINT;           (* number of cylinders *)
  137.     cylSectors * : LONGINT;          (* number of sectors/cylinder *)
  138.     heads * : LONGINT;               (* number of surfaces *)
  139.     trackSectors * : LONGINT;        (* number of sectors/track *)
  140.     bufMemType * : LONGINT;          (* preferred buffer memory type *)
  141.                             (* (usually MEMF_PUBLIC) *)
  142.     deviceType * : SHORTINT;          (* codes as defined in the SCSI-2 spec*)
  143.     flags * : SHORTSET;               (* flags, including removable *)
  144.     reserved * : INTEGER;
  145.   END;
  146.  
  147. CONST
  148.  
  149. (* device types *)
  150.   directAccess     * = 0;
  151.   sequentialAccess * = 1;
  152.   printer          * = 2;
  153.   processor        * = 3;
  154.   worm             * = 4;
  155.   cdRom            * = 5;
  156.   scanner          * = 6;
  157.   opticalDisk      * = 7;
  158.   mediumChanger    * = 8;
  159.   communication    * = 9;
  160.   unknown          * = 31;
  161.  
  162. (* flags *)
  163.   removable        * = 0;
  164.  
  165. (*
  166. ** raw read and write can be synced with the index pulse.  This flag
  167. ** in io request's IO_FLAGS field tells the driver that you want this.
  168. *)
  169.  
  170.   indexSync        * = 4;
  171.  
  172. (*
  173. ** raw read and write can be synced with a 04489H sync pattern.  This flag
  174. ** in io request's IO_FLAGS field tells the driver that you want this.
  175. *)
  176.   wordSync         * = 5;
  177.  
  178.  
  179. (* labels are TD_LABELSIZE bytes per sector *)
  180.  
  181.   labelSize        * = 16;
  182.  
  183. (*
  184. ** This is a bit in the FLAGS field of OpenDevice.  If it is set, then
  185. ** the driver will allow you to open all the disks that the trackdisk
  186. ** driver understands.  Otherwise only 3.5" disks will succeed.
  187. *)
  188.  
  189.   allowNon35       * = 0;
  190.  
  191. (*
  192. **  If you set the TDB_ALLOW_NON_3_5 bit in OpenDevice, then you don't
  193. **  know what type of disk you really got.  These defines are for the
  194. **  TD_GETDRIVETYPE command.  In addition, you can find out how many
  195. **  tracks are supported via the TD_GETNUMTRACKS command.
  196. *)
  197.  
  198.   drive35          * = 1;
  199.   drive525         * = 2;
  200.   drive35150rpm    * = 3;
  201.  
  202. (*
  203.  *--------------------------------------------------------------------
  204.  *
  205.  * Driver error defines
  206.  *
  207.  *--------------------------------------------------------------------
  208.  *)
  209.  
  210.   notSpecified      * = 20;      (* general catchall *)
  211.   noSecHdr          * = 21;      (* couldn't even find a sector *)
  212.   badSecPreamble    * = 22;      (* sector looked wrong *)
  213.   badSecID          * = 23;      (* ditto *)
  214.   badHdrSum         * = 24;      (* header had incorrect checksum *)
  215.   badSecSum         * = 25;      (* data had incorrect checksum *)
  216.   tooFewSecs        * = 26;      (* couldn't find enough sectors *)
  217.   badSecHdr         * = 27;      (* another "sector looked wrong" *)
  218.   writeProt         * = 28;      (* can't write to a protected disk *)
  219.   diskChanged       * = 29;      (* no disk in the drive *)
  220.   seekError         * = 30;      (* couldn't find track 0 *)
  221.   noMem             * = 31;      (* ran out of memory *)
  222.   badUnitNum        * = 32;      (* asked for a unit > NUMUNITS *)
  223.   badDriveType      * = 33;      (* not a drive that trackdisk groks *)
  224.   driveInUse        * = 34;      (* someone else allocated the drive *)
  225.   postReset         * = 35;      (* user hit reset; awaiting doom *)
  226.  
  227. TYPE
  228.  
  229. (*
  230.  *--------------------------------------------------------------------
  231.  *
  232.  * public portion of the unit structure
  233.  *
  234.  *--------------------------------------------------------------------
  235.  *)
  236.  
  237.   PublicUnitPtr * = UNTRACED POINTER TO PublicUnit;
  238.   PublicUnit * = STRUCT (unit * : e.Unit)          (* base message port *)
  239.     comp01Track * : INTEGER;        (* track for first precomp *)
  240.     comp10Track * : INTEGER;        (* track for second precomp *)
  241.     comp11Track * : INTEGER;        (* track for third precomp *)
  242.     stepDelay * : LONGINT;          (* time to wait after stepping *)
  243.     settleDelay * : LONGINT;        (* time to wait after seeking *)
  244.     retryCnt * : SHORTINT;          (* # of times to retry *)
  245.     pubFlags * : SHORTSET;          (* public flags, see below *)
  246.     currTrk * : INTEGER;            (* track the heads are over... *)
  247.                                     (* ONLY ACCESS WHILE UNIT IS STOPPED! *)
  248.     calibrateDelay * : LONGINT;     (* time to wait after stepping *)
  249.                                     (* during a recalibrate *)
  250.     counter * : LONGINT;            (* counter for disk changes... *)
  251.                                     (* ONLY ACCESS WHILE UNIT IS STOPPED! *)
  252.   END;
  253.  
  254. CONST
  255.  
  256. (* flags for tdu_PubFlags *)
  257.   noClick          * = 0;
  258.  
  259. END TrackDisk.
  260.  
  261.